<?php
/**
 * Created by PhpStorm.
 * User: lijiao
 * Date: 15/7/18
 * Time: 上午10:21
 */

namespace app\controllers;


class TestController extends BaseController
{
    public $enableCsrfValidation = false;
    public function actionImage()
    {
        $this->layout = false;
        return $this->render('index');
    }


    public static function genImgPath($ext = ''){
        $folder = date('Ym/d');
        $filename = time() . rand(1000, 9999);
        return $folder.'/'.$filename. '.' .$ext;
    }

    public static function initDir($file){
        $dir = dirname($file);
        if( ! file_exists($dir)){
            if( !mkdir($dir, 0777, true)){
                \Yii::trace('@@create folder failed!');
                return false;
            }
        }
        return true;
    }
}